

import { getCenterData } from '../../config/https'// 分销中心

const app = getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {
    // src2:'',       //二维码
    show: false,  //数据加载动画
    navUrl:'',   //跳转地址
    center:'',    //分销中心数据
    Districenter:[
      { id: 1, src: "../../icn/team.png", title: "我的团队"},
      { id: 2, src: "../../icn/promote1.png", title: "我要推广" },
      { id: 3, src: "../../icn/order.png", title: "分销订单"},
      { id: 4, src: "../../icn/detail.png", title: "提现明细"},
      { id: 5, src: "../../icn/withdrawal.png", title: "我要提现 "},
      { id: 6, src: "../../icn/gzsm.png", title: "分销规则" }
    ],
  },
 navget(){ //跳转
   let navUrl = this.data.navUrl;
   wx.navigateTo({
     url: navUrl,
   })
 },

  navgetto(e){ //点击列表
    let id=e.currentTarget.dataset.id;
    let center = this.data.center;
    if (id == 1) { //我的团队
        this.setData({ navUrl:"/pages/team/team"})
        this.navget()//跳转

    } else if (id == 2) { //我要推广
        this.setData({ navUrl: "/pages/impromote/impromote" })
        this.navget()//跳转

    } else if (id == 3) { //分销订单
        this.setData({ navUrl: "/pages/oforders/oforders" })
        this.navget()//跳转

    } else if (id == 4) { //提现明细
        this.setData({ navUrl: "/pages/Thedetail/Thedetail" })
        this.navget()//跳转

    } else if (id == 5) {  //我要提现
        this.setData({ navUrl: "/pages/withdrawal/withdrawal?can_withdraw=" + center.can_withdraw })
        this.navget()//跳转

    } else if (id == 6) {   //分销规则
        this.setData({ navUrl: "/pages/Distribution/Distribution" })
        this.navget()//跳转
  } 
   
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.setData({ show: true }) //数据加载动画  
  },

  
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
    this.setData({ show: false }) //数据加载动画
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    getCenterData({
    }).then(res => {
      this.setData({
        center: res
      })
      wx.setStorage({
        key: 'one_count',
        data: res.team_num.one_count,
      })
      wx.setStorage({
        key: 'two_count',
        data: res.team_num.two_count,
      })
      console.log(res)
    }).catch(err => { //请求失败
      console.log(res)
    })
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {
    let pages = getCurrentPages().length - 1; //三级页面 返回一级页
    wx.navigateBack({
      delta: pages 
    })
  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})